package in.muton.edushare.pages.user;

import in.muton.edushare.pages.EduShareBasePage;
import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.edushare.wicket.models.CayenneList;
import in.muton.edushare.wicket.models.InnerList;
import in.muton.panels.paginator.EntityListing;

import java.util.List;

import org.apache.wicket.model.IModel;

import com.edushare.common.dao.GroupsDAO;
import com.edushare.common.vo.Groups;

public class GroupListPanel extends EdusharePanel {

	private static final long serialVersionUID = -2921159702225999422L;

	public GroupListPanel(String id, EduShareBasePage page) {
		super(id, page);
		add(new EntityListing<Groups>("thumbList", new InnerList<Groups>() {
			private static final long serialVersionUID = -5396409052930253629L;

			@Override
			public List<IModel<Groups>> getObject() {
				return new CayenneList<Groups>(getMyGroups()).getObject();
			}
		}, page));
	}

	public List<Groups> getMyGroups() {
		return new GroupsDAO(getORMInterface()).getMyGroups(getLoggedInUser());
	}

}
